resource "alicloud_cdn_domain_new" "main" {
  domain_name                   = var.cdn_domain_name
  cdn_type                      = var.cdn_type
  scope                         = var.cdn_scope
  tags                          = var.tags
  dynamic "sources" {
    for_each            = var.cdn_sources
    content {
      content           = lookup(sources.value, "content", null)
      type              = lookup(sources.value, "type", null)
      priority          = lookup(sources.value, "priority", null)
      port              = lookup(sources.value, "port", null)
      weight            = lookup(sources.value, "weight", null)
    }
  }  
  dynamic "certificate_config" {
    for_each                    = var.cdn_certificate_config
    content {
      server_certificate_status = lookup(certificate_config.value, "server_certificate_status", null)
      server_certificate        = lookup(certificate_config.value, "server_certificate", null)
      private_key               = lookup(certificate_config.value, "private_key", null)
      cert_name                 = lookup(certificate_config.value, "cert_name", null)
      force_set                 = lookup(certificate_config.value, "force_set", null)
      cert_type                 = lookup(certificate_config.value, "cert_type", null)
    }
  }    
}
